﻿Imports System.Data
Partial Class Default2
    Inherits System.Web.UI.Page
    Dim ocnTrabajo As New Negocio.Trabajo
    Dim ocnProfesor As New Negocio.Profesor

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            ocnTrabajo.RegistrarCAL(Me.TBexpediente.Text, Me.TBresolucioncal.Text, CDate(Me.TBfecha.Text))
            Me.GridView3.DataSource = ocnTrabajo.obtenerNotaExpedienteCAL(Me.TBexpediente.Text)
            Me.GridView3.DataBind()
        Catch ex As Exception
            Session.Add("Error", ex.Message)
            Response.Redirect("ManejarErrores.aspx")
        End Try
    End Sub

    Protected Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        Try
            ocnTrabajo.RegistrarProfesorNota(Me.TBexpediente.Text, Me.TBprofesor.SelectedValue)
            Me.GridView4.DataSource = ocnTrabajo.obtenerNotasProfesores(Me.TBexpediente.Text)
            Me.GridView4.DataBind()

        Catch ex As Exception
            Session.Add("Error", ex.Message)
            Response.Redirect("ManejarErrores.aspx")
        End Try
    End Sub

    Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        Try
            Me.TBexpediente.Text = Me.ListBoxExpediente.SelectedValue
            Me.GridView1.DataSource = ocnTrabajo.obtenerTrabajoExpediente(Me.ListBoxExpediente.SelectedValue)
            Me.GridView1.DataBind()
        Catch ex As Exception
            Session.Add("Error", ex.Message)
            Response.Redirect("ManejarErrores.aspx")
        End Try
    End Sub

    Protected Sub ListBoxExpediente_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBoxExpediente.Init
        Dim ds As New DataSet
        ds = ocnTrabajo.obtenerTrabajosFinales()
        With Me.ListBoxExpediente
            .DataSource = ds.Tables("TrabajosFinales").DefaultView
            .DataTextField = "nombreTrabajo"
            .DataValueField = "nroExpediente"
        End With
        Me.ListBoxExpediente.DataBind()
    End Sub

    Protected Sub TBprofesor_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles TBprofesor.Init
        Dim ds As New DataSet
        ds = ocnProfesor.obtenerProfesores()
        With Me.TBprofesor
            .DataSource = ds.Tables("Profesores").DefaultView
            .DataTextField = "nombre"
            .DataValueField = "dni"

        End With
        Me.TBprofesor.DataBind()
    End Sub


End Class
